The present invention relates to methods, systems and software for compressing graphics files and is directed in particular to the compression of vector graphics.
Graphic images are used on the vast majority of internet and internet websites. When a web page is accessed, these images must be downloaded and displayed within a user's browser. The size of the data file defining an image greatly influences the time taken to download the file and hence the delay a user experiences when viewing these images on a site. It is desirable, therefore, to minimise the size of the image data files that must be downloaded.
Unlike bitmap graphics, where the image is defined as an array of pixels, vector graphics represent images in terms of geometric formulae, each image essentially being made up from a series of curves and straight lines each having a start point and at least a direction. This basic information is supplemented by a variety of line styles and fill styles to define a complete image.
In many cases, vector graphics require less data than bitmap graphics and hence the resultant file size for representing the same image is smaller. For this reason, vector graphics are commonly used to draw images, both static and animated, on web pages and in other environments where file sizes need to be minimised.
Vector images also have the advantage that they can be more easily resized and stretched compared to bitmap graphics. Further, since the actual generation of the pixels to draw the image is left to the application and device to which the image is supplied, any changes in the scale and shape do not tend to affect the quality of the image since the image is effectively recalculated in situ.
For web based vector graphics, a popular format is that offered by Macromedia Inc.'s Flash environment. Flash is a vector graphic based animation technology which uses a downloadable plug-in to play Flash files (identified by a swf extension and typically referred to as SWF—“swiff”— files) through a user's browser.
The SWF file format is well documented and, for the present purposes, it is not necessary to set out the detail of this format here. A detailed explanation of the format can be obtained from Macromedia Inc., for example from their website at http://www.macromedia.com and is also found at http://www.openswf.org. A brief overview of the format is set out below by way of background to the present invention.
A SWF file stores information in binary format and is constructed as a sequence of data blocks referred to as “tags”. Each SWF file starts with a header tag, is followed by a sequence of tags, which define the flash “movie”, and finishes with an end tag to mark the end of the file for the player.
The header tag contains generic information for the whole file, including, for example, the file size in bytes, the size of the picture, and the frame rate of the SWF movie.
Each of the subsequent sequence of tags comprises a unique tag code, an indication of the total length of data in the tag, and the data itself. There are two principal types of tag: definition tags and control tags.
Definition tags store the content of a SWF movie. Vector graphics data defining shapes is stored as data blocks in the definition tags (apart from such vector data, definition tags can also store sounds and bit maps used in the movie). The geometry of shapes is defined as a sequence of curves and/or straight lines. The geometrical information can be supplemented by a variety of fill and line styles. Each definition tag or shape tag representing an individual shape is assigned a unique identifier known as a “character ID” to identify the shape represented by that definition tag for use by other tags.
The definition tags can also define higher order “symbols” using sprite tags by referring to the previously defined shapes or other symbols which may be organised in a hierarchical complex structure. The symbols themselves can be movie clips of their own consisting of several frames.
The second type of tag is a control tag. These tags are used to define, amongst other things, the flow of the movie, the placement of shapes (defined by the placement tags), and playing accompanying audio files. Whilst placing shapes, the control tag refers to the shape by means of its character ID. Placement tags optionally allow geometric and colour transformations to be applied to the original shape, thereby permitting a degree of flexibility and controlling the appearance of the original shape on the screen. Without placing a character using a placement tag the character will not be displayed. A geometric transformation accompanying a placement tag includes a scaling factor for effecting the transformation. The scaling factor is exploited to achieve compression in the present invention. A single shape definition may be re-used several times by various placement tags.
The vector shapes in SWF are defined by quadratic Bezier curves (requiring three points) and/or straight lines (requiring two end points). The point co-ordinates are defined in a device independent co-ordinate system which is not dependent on a pixelated bit map. The point co-ordinates are stored as integer co-ordinate values, in a unit of measurement called a TWIP. A TWIP is defined as one twentieth of a point which is a traditional measure in printing. In the context of an SWF file, a TWIP is considered to be one twentieth of a logical pixel. Thus, a rectangle 800 TWIPS wide by 400 TWIPS high would be rendered as 40×20 logical pixels. The number of bits occupied by a co-ordinate depends on its value. Large co-ordinate values require more bits compared to smaller co-ordinate values. The SWF format allocates just enough bits to precisely represent a given co-ordinate value.
In this way, the SWF file format provides a succinct representation of line shapes using a vector graphic approach. However, the nature of the software graphics world is such that there is always a desire to reduce file sizes further.
Accordingly, one aspect of the present invention provides a method of manipulating a vector graphics data file representative of at least one graphics element defined by a set of co-ordinate values in a graphics image, the method comprising the step of scaling down the at least one graphics element by applying a scaling factor to the set of co-ordinate values defining the at least one graphics element.
Preferably, each of the co-ordinate values is represented by a bit sequence and the step of applying the scaling factor comprises the step of eliminating at least the least significant bit from the co-ordinate values.
Conveniently, the scaling factor is 2n where n is an integer value of one or more and comprises the number of bits to be removed from the bit sequence.
Advantageously, the step of applying the scaling factor comprises the step of dividing the co-ordinate values by the scaling factor, the scaling factor having a value greater than 1.
Preferably, each of the co-ordinate values is represented by a bit sequence and the scaling factor has a value which lies between 2n and 2n+1, where n and n+1 are integer values representing the number of bits to be removed from the bit sequence.
Conveniently, the scaling factor is applied to all co-ordinate values used to define the at least one graphics element.
Advantageously, the data file is representative of a plurality of graphics elements, at least one of which has a respective scaling factor applied thereto.
Preferably, respective scaling factors are applied to respective ones of the graphics elements.
Conveniently, the further step of scaling up the at least one graphics element by applying an inverse of the scaling factor to the set of scaled co-ordinate values defining the at least one graphics element.
Advantageously, a predetermined scaling factor is applied to the co-ordinate values in the vector graphics data file.
Conveniently, the method comprises the step of applying a further scaling factor to the co-ordinate values in the vector graphics data file.
Preferably, the method comprises the further step of analysing the co-ordinate values in the vector graphics file and determining therefrom an appropriate scaling factor to be applied.
Advantageously, all the graphics elements are scaled up by an inverse of the scaling factor previously applied thereto.
Preferably, the data file comprises a series of frames, each frame showing at least one graphics element to which a scaling factor can be applied.
Conveniently, the step of applying a scaling factor to the set of co-ordinate values defining the at least one graphics element is carried out selectively on a frame by frame basis.
Advantageously, the scaling factor applied to a particular graphics element is selectable on a frame by frame basis.
Preferably, the scaling factor is applied to the at least one graphics element by setting a first scaling factor for the graphics element in one frame and setting a second scaling factor for the graphics element in another frame and applying a scaling factor between the first scaling factor and the second scaling factor to the graphics element for the frames between the one frame and the other frame.
Conveniently, the scaling factor is applied to the at least one graphics element in the intervening frames, as a linear function between the one frame and the other frame.
Advantageously, saving the vector graphics data file incorporating the scaled set of co-ordinate values and the respective scaling factors applied thereto.
Preferably, the step of reading the re-saved file and scaling up the at least one graphics element by applying an inverse of the scaling factor to the set of scaled co-ordinate values defining the at least one graphics element; and displaying the at least one graphics element.
Conveniently, the further steps of scaling up the at least one graphics element; displaying the graphics image including the graphics element; applying another scaling factor to the set of co-ordinate values defining the at least one graphics element; applying an inverse of the scaling factor to the set of co-ordinate values defining the at least one graphics element; and displaying the graphics image including the graphics element having the further scaling factor and inverse scaling factor applied thereto.
Advantageously, a further step of re-saving the data file is provided to incorporate the set of co-ordinate values scaled down by the further scaling factor.
Preferably, the method comprises the step of parsing a data file to extract vector graphics data representing individual graphics elements and then carrying out the scaling down step on one or more of the graphics elements.
Advantageously, the data file is a multimedia data file.
Preferably, the data file is a SWF file.
Conveniently, the method comprises the step of reconstituting the data file incorporating the scaled down co-ordinate values of the graphics elements.
Preferably, a constituent of the graphics element defined by the set of co-ordinate values has a line weight assigned thereto, which line weight is scaled down and assigned a compensating line weight such that when the graphics element is scaled up for display the line weight of the graphics element appears to a user to be substantially as the uncompressed original line weight assigned thereto.
Another aspect of the present invention provides a method of previewing a vector graphics image composed of a plurality of graphics elements comprising the steps of:
parsing a vector graphics data file into individual graphics elements;
selecting at least one graphics element;
selecting and applying a scaling factor to a set of co-ordinate values defining the at least one selected graphics element;
applying an inverse of the scaling factor to the set of co-ordinate values defining the at least one selected graphics element;
displaying the graphics image including the graphics element having the scaling factor and inverse scaling factor applied thereto; and
providing an indication of data file compression as a result of said scaling such that the effect of the scaling on image quality and data file size can be appreciated.
Conveniently, the further step of varying the scaling factor applied to the set of co-ordinate values for the at least one graphics element during display of the graphics element.
Advantageously, the step of applying a scaling factor to the set of co-ordinate values defining the at least one selected graphics element is carried out selectively on a frame by frame basis.
Preferably, the scaling factor applied to a particular graphics element is selectable on a frame by frame basis.
Advantageously, said indication of data file compression to a user is graphical, numerical or audible.
Conveniently, the method of playing back a vector graphics data file manipulated in accordance with any preceding statement, comprises the steps of reading the vector graphics data file and extracting therefrom the scaled down set of co-ordinate values defining the at least one graphics element and the respective scaling factor applied to the set of co-ordinate values; applying an inverse of the respective scaling factors to the set of scaled co-ordinate values defining the at least one graphics element; and displaying the at least one graphics element.
Another aspect of the present invention provides a method of manipulating a vector graphics data file representative of at least one graphics element defined by a set of co-ordinate values in a graphics image, the method comprising the step of scaling down the at least one graphics element by eliminating at least a least significant bit from the co-ordinate values defining the at least one graphics element.
Preferably, an authoring tool comprising a computer program adapted to perform the steps of any of the above method statements, when the program is run on a computer.